package com.llu.serial;

import com.llu.serial.bean.Student;

import java.io.*;

public class BaseTest {
    public static void main(String[] args) throws Exception {

//        serial();
        deserial();
    }
    // 序列化
    public static void serial() throws IOException {
        Student llu = new Student("llu", 18);
        llu.setPhone("1231231231");
        System.out.println(llu);
        File file = new File("llu.bin");
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream(file));
        objectOutputStream.writeObject(llu);
    }
    // 反序列化
    public static void deserial() throws Exception {
        File file = new File("llu.bin");
        ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream(file));
        Student llu = (Student) objectInputStream.readObject();
        System.out.println(llu);
    }
}
